
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>12.1网络 · 元服务开发实践</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="坚果派">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mind-maps/mindmaps.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-ace/ace.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-lou/lou.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"repo":"jianguo888/docsify","types":["star","watch","fork"],"size":"small"};
    </script>

    </head>
    <body>
         
<div class="donate-modal modal">
  <div class="modal-header">
    <div>
      <span>
        <img
          id="modal-avatar"
          class="modal-avatar"
          src="https://luckly007.oss-cn-beijing.aliyuncs.com/uPic/avatar.jpg"
        />
      </span>
      <span id="nickname"> 坚果 </span>
      <p class="modal-close close" onclick="closeDonateModal()">×</p>
    </div>
    <div class="message">
      <div class="tip">
        <i></i>
        <span>随意打赏，但不要超过一顿早餐钱 💕</span>
      </div>
    </div>
  </div>
  <div class="modal-content">
    <div class="modal-pay-way">
      <div id="wxpay" onclick="showDonateImg(0)">
        <input
          type="radio"
          name="pay-way"
          value="wxpay"
          class="zs-type"
          checked="checked"
        />
        <span>
          <img
            id="wxpay-logo"
            src=""
          />
        </span>
      </div>
      <div id="alipay" onclick="showDonateImg(1)">
        <input type="radio" name="pay-way" value="alipay" class="zs-type" />
        <span>
          <img
            id="alipay-logo"
            src=""
          />
        </span>
      </div>
    </div>
    <div class="modal-pay-qrcode">
      <img id="wxpay-code" src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png" />
      <img
        id="alipay-code"
        src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png"
        hidden
      />
    </div>
  </div>
</div>
<div class="mask"></div>


<div class="book">
  <div class="header-inner">
    <!-- LOGO -->
    <div class="logo"></div>
    <span class="title"></span>

    <!-- Search -->
    
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>


    <!-- Nav -->
    <ul class="header-nav">
      <li>
        <a href="https://www.gitbook.com/" target="_blank">坚果派官网</a>
      </li><li>
        <a href="https://www.npmjs.com/package/package" target="_blank">ArkUI实战</a>
      </li><li>
        <a href="https://space.bilibili.com/480883651" target="_blank">HarmonyOS NEXT应用开发</a>
      </li><li>
        <a href="https://blog.51cto.com/jianguo" target="_blank">OpenHarmony应用开发</a>
      </li>
    </ul>
  </div>

  <div class="book-summary">
    <div class="book-summary-title">文档目录</div>
     
    <nav role="navigation">


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    1.前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter2/Why.html">
            
                <a href="../chapter2/Why.html">
            
                    
                    2.为什么要这个专栏？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    3.元服务概述
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter3/3.1什么是元服务.html">
            
                <a href="../chapter3/3.1什么是元服务.html">
            
                    
                    3.1什么是元服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter3/3.2元服务特征以及使用场景.html">
            
                <a href="../chapter3/3.2元服务特征以及使用场景.html">
            
                    
                    3.2元服务特征及使用场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter3/3.3元服务程序包基础知识.html">
            
                <a href="../chapter3/3.3元服务程序包基础知识.html">
            
                    
                    3.3元服务程序包基础知识
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter4/SUMMARY.html">
            
                <a href="../chapter4/SUMMARY.html">
            
                    
                    4.元服务开发流程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter4/4.1开发前.html">
            
                <a href="../chapter4/4.1开发前.html">
            
                    
                    4.1开发前
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter4/4.2开发中.html">
            
                <a href="../chapter4/4.2开发中.html">
            
                    
                    4.2开发中
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter4/4.3打包.html">
            
                <a href="../chapter4/4.3打包.html">
            
                    
                    4.3打包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter4/4.4测试.html">
            
                <a href="../chapter4/4.4测试.html">
            
                    
                    4.4测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter4/上架.md">
            
                <span>
            
                    
                    4.5上架
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    5.开发第一个元服务
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter5/5.1创建元服务工程.html">
            
                <a href="../chapter5/5.1创建元服务工程.html">
            
                    
                    5.1创建元服务工程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter5/5.2生成元服务图标.html">
            
                <a href="../chapter5/5.2生成元服务图标.html">
            
                    
                    5.2生成元服务图标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter5/5.3构建元服务页面.html">
            
                <a href="../chapter5/5.3构建元服务页面.html">
            
                    
                    5.3构建元服务页面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter5/5.4新建元服务卡片.html">
            
                <a href="../chapter5/5.4新建元服务卡片.html">
            
                    
                    5.4新建元服务卡片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter5/5.5使用真机运行元服务.html">
            
                <a href="../chapter5/5.5使用真机运行元服务.html">
            
                    
                    5.5使用真机运行元服务
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    6.元服务开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter6/6.1元服务开发准备.html">
            
                <a href="../chapter6/6.1元服务开发准备.html">
            
                    
                    6.1元服务开发准备
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter6/6.2元服务框架开发.html">
            
                <a href="../chapter6/6.2元服务框架开发.html">
            
                    
                    6.2元服务框架开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter6/6.3UI开发.html">
            
                <a href="../chapter6/6.3UI开发.html">
            
                    
                    6.3UI开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter6/6.4服务卡片开发.html">
            
                <a href="../chapter6/6.4服务卡片开发.html">
            
                    
                    6.4服务卡片开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter6/6.5基础能力开发.html">
            
                <a href="../chapter6/6.5基础能力开发.html">
            
                    
                    6.5基础能力开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter6/6.6经营履约能力开发.html">
            
                <a href="../chapter6/6.6经营履约能力开发.html">
            
                    
                    6.6经营履约能力开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    7.服务卡片开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter7/7.1Form Kit简介.html">
            
                <a href="../chapter7/7.1Form Kit简介.html">
            
                    
                    7.1Form Kit简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" >
            
                <span>
            
                    
                    7.2ArkTS卡片运行机制
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-modules-V5">
            
                    
                    7.3ArkTS卡片相关模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-creation-V5">
            
                    
                    7.4创建一个ArkTS卡片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-configuration-V5">
            
                    
                    7.5配置卡片的配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-lifecycle-V5">
            
                    
                    7.6卡片生命周期管7.6卡片生命周期管理理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-page-V5">
            
                    
                    7.7开发卡片页面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-event-V5">
            
                    
                    7.8开发卡片事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-ui-widget-interaction-V5">
            
                    
                    7.9卡片数据交互
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                    8.金额转大写实战
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter8/8.1金额转大写.html">
            
                <a href="../chapter8/8.1金额转大写.html">
            
                    
                    8.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" >
            
                <span>
            
                    
                    9.运行调试元服务
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter9/9.1调试元服务">
            
                <span>
            
                    
                    9.1调试元服务
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" >
            
                <span>
            
                    
                    10.发布元服务
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter10/10.1元服务审核指南">
            
                <span>
            
                    
                    10.1元服务审核指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" >
            
                <span>
            
                    
                    10.2发布前自检
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" >
            
                <span>
            
                    
                    10.3 打包发布版本
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" >
            
                <span>
            
                    
                    10.4邀请测试
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" >
            
                <span>
            
                    
                    10.5元服务备案
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" >
            
                <span>
            
                    
                    10.6发布元服务
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" >
            
                <span>
            
                    
                    11.FAQ
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter11/11.1元服务是什么？.html">
            
                <a href="../chapter11/11.1元服务是什么？.html">
            
                    
                    11.1元服务是什么？和App什么关系？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter11/11.2元服务与App、卡片、小程序有什么区别.html">
            
                <a href="../chapter11/11.2元服务与App、卡片、小程序有什么区别.html">
            
                    
                    11.2元服务与App、卡片、小程序有什么区别？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter11/11.3开发App和开发元服务如何选择？.html">
            
                <a href="../chapter11/11.3开发App和开发元服务如何选择？.html">
            
                    
                    11.3开发App和开发元服务如何选择？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter11/11.4开发了App，再开发元服务有什么价值.html">
            
                <a href="../chapter11/11.4开发了App，再开发元服务有什么价值.html">
            
                    
                    11.4开发了App，再开发元服务有什么价值？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter11/11.5对接华为支付的关键信息.html">
            
                <a href="../chapter11/11.5对接华为支付的关键信息.html">
            
                    
                    11.5对接华为支付的关键信息
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" >
            
                <span>
            
                    
                    12.基础能力开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.12.1" data-path="12.1网络.html">
            
                <a href="12.1网络.html">
            
                    
                    12.1网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-database-V5">
            
                    
                    数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-file-development-V5">
            
                    
                    文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-audio-development-V5">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-avsession-development-V5">
            
                    
                    媒体会话
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-camera-V5">
            
                    
                    相机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-media-library-development-V5">
            
                    
                    媒体库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-image-development-V5">
            
                    
                    图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-window-development-V5">
            
                    
                    窗口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-device-management-V5">
            
                    
                    设备管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-connectivity-V5">
            
                    
                    基础通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-contacts-V5">
            
                    
                    联系人
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-web-development-V5">
            
                    
                    Web
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-service-sharing-V5">
            
                    
                    元服务分享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-ai-development-V5">
            
                    
                    AI能力
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-health-service-development-V5">
            
                    
                    运动健康
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-cloud-foundation-development-V5">
            
                    
                    云开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-security-development-V5">
            
                    
                    安全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-localization-V5">
            
                    
                    本地化开发服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-backgroundtask-V5">
            
                    
                    长时任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-log-development-V5">
            
                    
                    日志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkts-utils-V5">
            
                    
                    ArkTS语言基础类库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkxtest-guidelines-V5">
            
                    
                    自动化测试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" >
            
                <span>
            
                    
                    13.经营履约能力开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../chapter13/13.1Account Kit.html">
            
                <a href="../chapter13/13.1Account Kit.html">
            
                    
                    13.1账号
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-push-development-V5">
            
                    
                    推送
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-code-scan-development-V5">
            
                    
                    扫码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-location-development-V5">
            
                    
                    位置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-map-development-V5">
            
                    
                    地图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-payment-development-V5">
            
                    
                    支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-iap-development-V5">
            
                    
                    应用内支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-ads-development-V5">
            
                    
                    广告
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" >
            
                <a target="_blank" href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-scenariofusion-development-V5">
            
                    
                    场景化组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>

</nav>
     
  </div>

  <!-- Content nav -->
  <div class="book-anchor">
    <div class="book-anchor-title"></div>

    <div class="book-anchor-body"></div>
  </div>

  <div class="book-body">
    
    <div class="body-inner">
       

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >12.1网络</a>
    </h1>
</div>



      <div class="page-wrapper" tabindex="-1" role="main">
        <div class="page-inner">
          
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
          <section class="normal markdown-section">
             
                <div id="vip-container">
                    <h2 id="&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6A21;&#x5757;&#x4E3B;&#x8981;&#x63D0;&#x4F9B;&#x4EE5;&#x4E0B;&#x529F;&#x80FD;&#xFF1A;"><a name="&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6A21;&#x5757;&#x4E3B;&#x8981;&#x63D0;&#x4F9B;&#x4EE5;&#x4E0B;&#x529F;&#x80FD;&#xFF1A;" class="plugin-anchor" href="#&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6A21;&#x5757;&#x4E3B;&#x8981;&#x63D0;&#x4F9B;&#x4EE5;&#x4E0B;&#x529F;&#x80FD;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6A21;&#x5757;&#x4E3B;&#x8981;&#x63D0;&#x4F9B;&#x4EE5;&#x4E0B;&#x529F;&#x80FD;&#xFF1A;</h2>
<ul>
<li><p><a href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-http-request-V5" target="_blank">HTTP&#x6570;&#x636E;&#x8BF7;&#x6C42;</a>&#xFF1A;&#x901A;&#x8FC7;HTTP&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x3002;</p>
</li>
<li><p><a href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-websocket-connection-V5" target="_blank">WebSocket&#x8FDE;&#x63A5;</a>&#xFF1A;&#x4F7F;&#x7528;WebSocket&#x5EFA;&#x7ACB;&#x670D;&#x52A1;&#x5668;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x53CC;&#x5411;&#x8FDE;&#x63A5;&#x3002;</p>
</li>
<li><p><a href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-net-connection-manager-V5" target="_blank">&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;</a>&#xFF1A;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;&#x63D0;&#x4F9B;&#x7BA1;&#x7406;&#x7F51;&#x7EDC;&#x4E00;&#x4E9B;&#x57FA;&#x7840;&#x80FD;&#x529B;&#xFF0C;&#x5305;&#x62EC;Wi-Fi/&#x8702;&#x7A9D;/Ethernet&#x7B49;&#x591A;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x4F18;&#x5148;&#x7EA7;&#x7BA1;&#x7406;&#x3001;&#x7F51;&#x7EDC;&#x8D28;&#x91CF;&#x8BC4;&#x4F30;&#x3001;&#x8BA2;&#x9605;&#x9ED8;&#x8BA4;/&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x3001;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;&#x3001;DNS&#x89E3;&#x6790;&#x7B49;&#x529F;&#x80FD;&#x3002;</p>
</li>
<li><p><a href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-net-mdns-V5" target="_blank">MDNS&#x7BA1;&#x7406;</a>&#xFF1A;MDNS&#x5373;&#x591A;&#x64AD;DNS&#xFF08;Multicast DNS&#xFF09;&#xFF0C;&#x63D0;&#x4F9B;&#x5C40;&#x57DF;&#x7F51;&#x5185;&#x7684;&#x672C;&#x5730;&#x670D;&#x52A1;&#x6DFB;&#x52A0;&#x3001;&#x79FB;&#x9664;&#x3001;&#x53D1;&#x73B0;&#x3001;&#x89E3;&#x6790;&#x7B49;&#x80FD;&#x529B;&#x3002;</p>
</li>
</ul>
<h2 id="http&#x6570;&#x636E;&#x8BF7;&#x6C42;"><a name="http&#x6570;&#x636E;&#x8BF7;&#x6C42;" class="plugin-anchor" href="#http&#x6570;&#x636E;&#x8BF7;&#x6C42;"><i class="fa fa-link" aria-hidden="true"></i></a>HTTP&#x6570;&#x636E;&#x8BF7;&#x6C42;</h2>
<p>&#x5E94;&#x7528;&#x901A;&#x8FC7;HTTP&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x8BF7;&#x6C42;&#xFF0C;&#x652F;&#x6301;&#x5E38;&#x89C1;&#x7684;GET&#x3001;POST&#x3001;OPTIONS&#x3001;HEAD&#x3001;PUT&#x3001;DELETE&#x3001;TRACE&#x3001;CONNECT&#x65B9;&#x6CD5;&#x3002;</p>
<h3 id="&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><a name="&#x63A5;&#x53E3;&#x8BF4;&#x660E;" class="plugin-anchor" href="#&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x53E3;&#x8BF4;&#x660E;</h3>
<p>HTTP&#x6570;&#x636E;&#x8BF7;&#x6C42;&#x529F;&#x80FD;&#x4E3B;&#x8981;&#x7531;http&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x3002;</p>
<p>&#x4F7F;&#x7528;&#x8BE5;&#x529F;&#x80FD;&#x9700;&#x8981;&#x7533;&#x8BF7;ohos.permission.INTERNET&#x6743;&#x9650;&#x3002;</p>
<p>&#x6D89;&#x53CA;&#x7684;&#x63A5;&#x53E3;&#x5982;&#x4E0B;&#x8868;&#xFF0C;&#x5177;&#x4F53;&#x7684;&#x63A5;&#x53E3;&#x8BF4;&#x660E;&#x8BF7;&#x53C2;&#x8003;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-http-V5" target="_blank">API&#x6587;&#x6863;</a>&#x3002;</p>
<table>
<thead>
<tr>
<th>&#x63A5;&#x53E3;&#x540D;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>createHttp()</td>
<td>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;http&#x8BF7;&#x6C42;&#x3002;</td>
</tr>
<tr>
<td>request()</td>
<td>&#x6839;&#x636E;URL&#x5730;&#x5740;&#xFF0C;&#x53D1;&#x8D77;HTTP&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#x3002;</td>
</tr>
<tr>
<td>destroy()</td>
<td>&#x4E2D;&#x65AD;&#x8BF7;&#x6C42;&#x4EFB;&#x52A1;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;headersReceive&apos;)</td>
<td>&#x8BA2;&#x9605;HTTP Response Header &#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>off(type: &apos;headersReceive&apos;)</td>
<td>&#x53D6;&#x6D88;&#x8BA2;&#x9605;HTTP Response Header &#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
</tbody>
</table>
<h3 id="request&#x63A5;&#x53E3;&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><a name="request&#x63A5;&#x53E3;&#x5F00;&#x53D1;&#x6B65;&#x9AA4;" class="plugin-anchor" href="#request&#x63A5;&#x53E3;&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><i class="fa fa-link" aria-hidden="true"></i></a>request&#x63A5;&#x53E3;&#x5F00;&#x53D1;&#x6B65;&#x9AA4;</h3>
<ol>
<li>&#x4ECE;@ohos.net.http&#x4E2D;&#x5BFC;&#x5165;http&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x3002;</li>
<li>&#x8C03;&#x7528;createHttp()&#x65B9;&#x6CD5;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;HttpRequest&#x5BF9;&#x8C61;&#x3002;</li>
<li>&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;on()&#x65B9;&#x6CD5;&#xFF0C;&#x8BA2;&#x9605;http&#x54CD;&#x5E94;&#x5934;&#x4E8B;&#x4EF6;&#xFF0C;&#x6B64;&#x63A5;&#x53E3;&#x4F1A;&#x6BD4;request&#x8BF7;&#x6C42;&#x5148;&#x8FD4;&#x56DE;&#x3002;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#x8BA2;&#x9605;&#x6B64;&#x6D88;&#x606F;&#x3002;</li>
<li>&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;request()&#x65B9;&#x6CD5;&#xFF0C;&#x4F20;&#x5165;http&#x8BF7;&#x6C42;&#x7684;url&#x5730;&#x5740;&#x548C;&#x53EF;&#x9009;&#x53C2;&#x6570;&#xFF0C;&#x53D1;&#x8D77;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#x3002;</li>
<li>&#x6309;&#x7167;&#x5B9E;&#x9645;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#xFF0C;&#x89E3;&#x6790;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</li>
<li>&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;off()&#x65B9;&#x6CD5;&#xFF0C;&#x53D6;&#x6D88;&#x8BA2;&#x9605;http&#x54CD;&#x5E94;&#x5934;&#x4E8B;&#x4EF6;&#x3002;</li>
<li>&#x5F53;&#x8BE5;&#x8BF7;&#x6C42;&#x4F7F;&#x7528;&#x5B8C;&#x6BD5;&#x65F6;&#xFF0C;&#x8C03;&#x7528;destroy()&#x65B9;&#x6CD5;&#x4E3B;&#x52A8;&#x9500;&#x6BC1;&#x3002;</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-comment">// &#x5F15;&#x5165;&#x5305;&#x540D;</span>
<span class="hljs-keyword">import</span> http from <span class="hljs-string">&apos;@ohos.net.http&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } from <span class="hljs-string">&apos;@ohos.base&apos;</span>;

<span class="hljs-comment">// &#x6BCF;&#x4E00;&#x4E2A;httpRequest&#x5BF9;&#x5E94;&#x4E00;&#x4E2A;HTTP&#x8BF7;&#x6C42;&#x4EFB;&#x52A1;&#xFF0C;&#x4E0D;&#x53EF;&#x590D;&#x7528;</span>
<span class="hljs-keyword">let</span> httpRequest = http.createHttp();
<span class="hljs-comment">// &#x7528;&#x4E8E;&#x8BA2;&#x9605;HTTP&#x54CD;&#x5E94;&#x5934;&#xFF0C;&#x6B64;&#x63A5;&#x53E3;&#x4F1A;&#x6BD4;request&#x8BF7;&#x6C42;&#x5148;&#x8FD4;&#x56DE;&#x3002;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#x8BA2;&#x9605;&#x6B64;&#x6D88;&#x606F;</span>
<span class="hljs-comment">// &#x4ECE;API 8&#x5F00;&#x59CB;&#xFF0C;&#x4F7F;&#x7528;on(&apos;headersReceive&apos;, Callback)&#x66FF;&#x4EE3;on(&apos;headerReceive&apos;, AsyncCallback)&#x3002; </span>
httpRequest.on(<span class="hljs-string">&apos;headersReceive&apos;</span>, (header) =&gt; {
  <span class="hljs-built_in">console</span>.info(<span class="hljs-string">&apos;header: &apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(header));
});
httpRequest.request(
  <span class="hljs-comment">// &#x586B;&#x5199;HTTP&#x8BF7;&#x6C42;&#x7684;URL&#x5730;&#x5740;&#xFF0C;&#x53EF;&#x4EE5;&#x5E26;&#x53C2;&#x6570;&#x4E5F;&#x53EF;&#x4EE5;&#x4E0D;&#x5E26;&#x53C2;&#x6570;&#x3002;URL&#x5730;&#x5740;&#x9700;&#x8981;&#x5F00;&#x53D1;&#x8005;&#x81EA;&#x5B9A;&#x4E49;&#x3002;&#x8BF7;&#x6C42;&#x7684;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x5728;extraData&#x4E2D;&#x6307;&#x5B9A;</span>
  <span class="hljs-string">&quot;EXAMPLE_URL&quot;</span>,
  {
    method: http.RequestMethod.POST, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;http.RequestMethod.GET</span>
    <span class="hljs-comment">// &#x5F00;&#x53D1;&#x8005;&#x6839;&#x636E;&#x81EA;&#x8EAB;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#x6DFB;&#x52A0;header&#x5B57;&#x6BB5;</span>
    header: {
      <span class="hljs-string">&apos;Content-Type&apos;</span>: <span class="hljs-string">&apos;application/json&apos;</span>
    },
    <span class="hljs-comment">// &#x5F53;&#x4F7F;&#x7528;POST&#x8BF7;&#x6C42;&#x65F6;&#x6B64;&#x5B57;&#x6BB5;&#x7528;&#x4E8E;&#x4F20;&#x9012;&#x8BF7;&#x6C42;&#x4F53;&#x5185;&#x5BB9;&#xFF0C;&#x5177;&#x4F53;&#x683C;&#x5F0F;&#x4E0E;&#x670D;&#x52A1;&#x7AEF;&#x534F;&#x5546;&#x786E;&#x5B9A;</span>
    extraData: <span class="hljs-string">&quot;data to send&quot;</span>,
    expectDataType: http.HttpDataType.STRING, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x6307;&#x5B9A;&#x8FD4;&#x56DE;&#x6570;&#x636E;&#x7684;&#x7C7B;&#x578B;</span>
    usingCache: <span class="hljs-literal">true</span>, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;true</span>
    priority: <span class="hljs-number">1</span>, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;1</span>
    connectTimeout: <span class="hljs-number">60000</span>, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;60000ms</span>
    readTimeout: <span class="hljs-number">60000</span>, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;60000ms</span>
    usingProtocol: http.HttpProtocol.HTTP1_1, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x534F;&#x8BAE;&#x7C7B;&#x578B;&#x9ED8;&#x8BA4;&#x503C;&#x7531;&#x7CFB;&#x7EDF;&#x81EA;&#x52A8;&#x6307;&#x5B9A;</span>
    usingProxy: <span class="hljs-literal">false</span>, <span class="hljs-comment">// &#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E0D;&#x4F7F;&#x7528;&#x7F51;&#x7EDC;&#x4EE3;&#x7406;&#xFF0C;&#x81EA;API 10&#x5F00;&#x59CB;&#x652F;&#x6301;&#x8BE5;&#x5C5E;&#x6027;</span>
  }, (err: BusinessError, data: http.HttpResponse) =&gt; {
    <span class="hljs-keyword">if</span> (!err) {
      <span class="hljs-comment">// data.result&#x4E3A;HTTP&#x54CD;&#x5E94;&#x5185;&#x5BB9;&#xFF0C;&#x53EF;&#x6839;&#x636E;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x89E3;&#x6790;</span>
      <span class="hljs-built_in">console</span>.info(<span class="hljs-string">&apos;Result:&apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(data.result));
      <span class="hljs-built_in">console</span>.info(<span class="hljs-string">&apos;code:&apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(data.responseCode));
      <span class="hljs-comment">// data.header&#x4E3A;HTTP&#x54CD;&#x5E94;&#x5934;&#xFF0C;&#x53EF;&#x6839;&#x636E;&#x4E1A;&#x52A1;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x89E3;&#x6790;</span>
      <span class="hljs-built_in">console</span>.info(<span class="hljs-string">&apos;header:&apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(data.header));
      <span class="hljs-built_in">console</span>.info(<span class="hljs-string">&apos;cookies:&apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(data.cookies)); <span class="hljs-comment">// 8+</span>
      <span class="hljs-comment">// &#x5F53;&#x8BE5;&#x8BF7;&#x6C42;&#x4F7F;&#x7528;&#x5B8C;&#x6BD5;&#x65F6;&#xFF0C;&#x8C03;&#x7528;destroy&#x65B9;&#x6CD5;&#x4E3B;&#x52A8;&#x9500;&#x6BC1;</span>
      httpRequest.destroy();
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;error:&apos;</span> + <span class="hljs-built_in">JSON</span>.stringify(err));
      <span class="hljs-comment">// &#x53D6;&#x6D88;&#x8BA2;&#x9605;HTTP&#x54CD;&#x5E94;&#x5934;&#x4E8B;&#x4EF6;</span>
      httpRequest.off(<span class="hljs-string">&apos;headersReceive&apos;</span>);
      <span class="hljs-comment">// &#x5F53;&#x8BE5;&#x8BF7;&#x6C42;&#x4F7F;&#x7528;&#x5B8C;&#x6BD5;&#x65F6;&#xFF0C;&#x8C03;&#x7528;destroy&#x65B9;&#x6CD5;&#x4E3B;&#x52A8;&#x9500;&#x6BC1;</span>
      httpRequest.destroy();
    }
  }
);
</code></pre>
<h2 id="&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;"><a name="&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;" class="plugin-anchor" href="#&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;</h2>
<h3 id="&#x7B80;&#x4ECB;"><a name="&#x7B80;&#x4ECB;" class="plugin-anchor" href="#&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7B80;&#x4ECB;</h3>
<p>&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;&#x63D0;&#x4F9B;&#x7BA1;&#x7406;&#x7F51;&#x7EDC;&#x4E00;&#x4E9B;&#x57FA;&#x7840;&#x80FD;&#x529B;&#xFF0C;&#x5305;&#x62EC;Wi-Fi/&#x8702;&#x7A9D;/Ethernet&#x7B49;&#x591A;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x4F18;&#x5148;&#x7EA7;&#x7BA1;&#x7406;&#x3001;&#x7F51;&#x7EDC;&#x8D28;&#x91CF;&#x8BC4;&#x4F30;&#x3001;&#x8BA2;&#x9605;&#x9ED8;&#x8BA4;/&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x3001;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;&#x3001;DNS&#x89E3;&#x6790;&#x7B49;&#x529F;&#x80FD;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x4FDD;&#x8BC1;&#x5E94;&#x7528;&#x7684;&#x8FD0;&#x884C;&#x6548;&#x7387;&#xFF0C;&#x5927;&#x90E8;&#x5206;API&#x8C03;&#x7528;&#x90FD;&#x662F;&#x5F02;&#x6B65;&#x7684;&#xFF0C;&#x5BF9;&#x4E8E;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x7684;API&#x5747;&#x63D0;&#x4F9B;&#x4E86;callback&#x548C;Promise&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x4EE5;&#x4E0B;&#x793A;&#x4F8B;&#x5747;&#x91C7;&#x7528;callback&#x51FD;&#x6570;&#xFF0C;&#x66F4;&#x591A;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x67E5;&#x9605;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5" target="_blank">API&#x53C2;&#x8003;</a>&#x3002;</p>
<p>&#x5F00;&#x53D1;&#x8BED;&#x8A00;&#xFF1A;JS&#x3001;C</p>
<h3 id="&#x57FA;&#x672C;&#x6982;&#x5FF5;"><a name="&#x57FA;&#x672C;&#x6982;&#x5FF5;" class="plugin-anchor" href="#&#x57FA;&#x672C;&#x6982;&#x5FF5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x57FA;&#x672C;&#x6982;&#x5FF5;</h3>
<ul>
<li>&#x7F51;&#x7EDC;&#x751F;&#x4EA7;&#x8005;&#xFF1A;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x7684;&#x63D0;&#x4F9B;&#x65B9;&#xFF0C;&#x6BD4;&#x5982;Wi-Fi&#x3001;&#x8702;&#x7A9D;&#x3001;Ethernet&#x7B49;&#x3002;</li>
<li>&#x7F51;&#x7EDC;&#x6D88;&#x8D39;&#x8005;&#xFF1A;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#xFF0C;&#x6BD4;&#x5982;&#x5E94;&#x7528;&#x6216;&#x7CFB;&#x7EDF;&#x670D;&#x52A1;&#x3002;</li>
<li>&#x7F51;&#x7EDC;&#x63A2;&#x6D4B;&#xFF1A;&#x68C0;&#x6D4B;&#x7F51;&#x7EDC;&#x6709;&#x6548;&#x6027;&#xFF0C;&#x907F;&#x514D;&#x5C06;&#x7F51;&#x7EDC;&#x4ECE;&#x53EF;&#x7528;&#x7F51;&#x7EDC;&#x5207;&#x6362;&#x5230;&#x4E0D;&#x53EF;&#x7528;&#x7F51;&#x7EDC;&#x3002;&#x5185;&#x5BB9;&#x5305;&#x62EC;&#x7ED1;&#x5B9A;&#x7F51;&#x7EDC;&#x63A2;&#x6D4B;&#x3001;DNS&#x63A2;&#x6D4B;&#x3001;HTTP&#x63A2;&#x6D4B;&#x53CA;HTTPS&#x63A2;&#x6D4B;&#x3002;</li>
<li>&#x7F51;&#x7EDC;&#x4F18;&#x9009;&#xFF1A;&#x5904;&#x7406;&#x591A;&#x7F51;&#x7EDC;&#x5171;&#x5B58;&#x65F6;&#x9009;&#x62E9;&#x6700;&#x4F18;&#x7F51;&#x7EDC;&#x3002;&#x5728;&#x7F51;&#x7EDC;&#x72B6;&#x6001;&#x3001;&#x7F51;&#x7EDC;&#x4FE1;&#x606F;&#x53CA;&#x8BC4;&#x5206;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;&#x88AB;&#x89E6;&#x53D1;&#x3002;</li>
</ul>
<h3 id="&#x573A;&#x666F;&#x4ECB;&#x7ECD;"><a name="&#x573A;&#x666F;&#x4ECB;&#x7ECD;" class="plugin-anchor" href="#&#x573A;&#x666F;&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x573A;&#x666F;&#x4ECB;&#x7ECD;</h3>
<p>&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;&#x7684;&#x5178;&#x578B;&#x573A;&#x666F;&#x6709;&#xFF1A;</p>
<ul>
<li>&#x63A5;&#x6536;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x901A;&#x77E5;</li>
<li>&#x83B7;&#x53D6;&#x6240;&#x6709;&#x6CE8;&#x518C;&#x7684;&#x7F51;&#x7EDC;</li>
<li>&#x6839;&#x636E;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x7684;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;</li>
<li>&#x4F7F;&#x7528;&#x5BF9;&#x5E94;&#x7F51;&#x7EDC;&#x89E3;&#x6790;&#x57DF;&#x540D;&#xFF0C;&#x83B7;&#x53D6;&#x6240;&#x6709;IP</li>
</ul>
<p>&#x4EE5;&#x4E0B;&#x5206;&#x522B;&#x4ECB;&#x7ECD;&#x5177;&#x4F53;&#x5F00;&#x53D1;&#x65B9;&#x5F0F;&#x3002;</p>
<h3 id="&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><a name="&#x63A5;&#x53E3;&#x8BF4;&#x660E;" class="plugin-anchor" href="#&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x53E3;&#x8BF4;&#x660E;</h3>
<p>&#x5B8C;&#x6574;&#x7684;JS API&#x8BF4;&#x660E;&#x4EE5;&#x53CA;&#x5B9E;&#x4F8B;&#x4EE3;&#x7801;&#x8BF7;&#x53C2;&#x8003;&#xFF1A;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5" target="_blank">&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#x7BA1;&#x7406;</a>&#x3002;</p>
<table>
<thead>
<tr>
<th>&#x63A5;&#x53E3;&#x540D;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>getDefaultNet(callback: AsyncCallback<nethandle>): void;</nethandle></td>
<td>&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x542B;&#x6709;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x7684;netId&#x7684;NetHandle&#x5BF9;&#x8C61;&#xFF0C;&#x4F7F;&#x7528;callback&#x56DE;&#x8C03;&#x3002;</td>
</tr>
<tr>
<td>getDefaultNetSync(): NetHandle;</td>
<td>&#x4F7F;&#x7528;&#x540C;&#x6B65;&#x65B9;&#x6CD5;&#x83B7;&#x53D6;&#x9ED8;&#x8BA4;&#x6FC0;&#x6D3B;&#x7684;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x3002;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;getNetCapabilities&#x53BB;&#x83B7;&#x53D6;&#x7F51;&#x7EDC;&#x7684;&#x7C7B;&#x578B;&#x3001;&#x62E5;&#x6709;&#x7684;&#x80FD;&#x529B;&#x7B49;&#x4FE1;&#x606F;&#x3002;</td>
</tr>
<tr>
<td>getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<netcapabilities>): void;</netcapabilities></td>
<td>&#x67E5;&#x8BE2;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x96C6;&#x4FE1;&#x606F;&#xFF0C;&#x4F7F;&#x7528;callback&#x56DE;&#x8C03;&#x3002;</td>
</tr>
<tr>
<td>createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection;</td>
<td>&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;NetConnection&#x5BF9;&#x8C61;&#xFF0C;netSpecifier&#x6307;&#x5B9A;&#x5173;&#x6CE8;&#x7684;&#x7F51;&#x7EDC;&#x7684;&#x5404;&#x9879;&#x7279;&#x5F81;&#xFF0C;timeout&#x662F;&#x8D85;&#x65F6;&#x65F6;&#x95F4;(&#x5355;&#x4F4D;&#x662F;&#x6BEB;&#x79D2;)&#xFF0C;netSpecifier&#x662F;timeout&#x7684;&#x5FC5;&#x8981;&#x6761;&#x4EF6;&#xFF0C;&#x4E24;&#x8005;&#x90FD;&#x6CA1;&#x6709;&#x5219;&#x8868;&#x793A;&#x5173;&#x6CE8;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;netAvailable&apos;, callback: Callback<nethandle>): void;</nethandle></td>
<td>&#x76D1;&#x542C;&#x6536;&#x5230;&#x7F51;&#x7EDC;&#x53EF;&#x7528;&#x7684;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;netCapabilitiesChange&apos;, callback: Callback&lt;{ netHandle: NetHandle, netCap: NetCapabilities }&gt;): void;</td>
<td>&#x76D1;&#x542C;&#x7F51;&#x7EDC;&#x80FD;&#x529B;&#x53D8;&#x5316;&#x7684;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;netLost&apos;, callback: Callback<nethandle>): void;</nethandle></td>
<td>&#x76D1;&#x542C;&#x7F51;&#x7EDC;&#x4E22;&#x5931;&#x7684;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;netUnavailable&apos;, callback: Callback<void>): void;</void></td>
<td>&#x76D1;&#x542C;&#x7F51;&#x7EDC;&#x4E0D;&#x53EF;&#x7528;&#x7684;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>register(callback: AsyncCallback<void>): void;</void></td>
<td>&#x6CE8;&#x518C;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x6216;&#x8005;createNetConnection&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x7F51;&#x7EDC;&#x7684;&#x76D1;&#x542C;&#x3002;</td>
</tr>
<tr>
<td>unregister(callback: AsyncCallback<void>): void;</void></td>
<td>&#x6CE8;&#x9500;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x6216;&#x8005;createNetConnection&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x7F51;&#x7EDC;&#x7684;&#x76D1;&#x542C;&#x3002;</td>
</tr>
</tbody>
</table>
<h3 id="&#x63A5;&#x6536;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x901A;&#x77E5;"><a name="&#x63A5;&#x6536;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x901A;&#x77E5;" class="plugin-anchor" href="#&#x63A5;&#x6536;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x901A;&#x77E5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x6536;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x901A;&#x77E5;</h3>
<ol>
<li><p>&#x58F0;&#x660E;&#x63A5;&#x53E3;&#x8C03;&#x7528;&#x6240;&#x9700;&#x8981;&#x7684;&#x6743;&#x9650;&#xFF1A;ohos.permission.GET_NETWORK_INFO&#x3002;</p>
<p>&#x6B64;&#x6743;&#x9650;&#x7EA7;&#x522B;&#x4E3A;normal&#xFF0C;&#x5728;&#x7533;&#x8BF7;&#x6743;&#x9650;&#x524D;&#xFF0C;&#x8BF7;&#x4FDD;&#x8BC1;&#x7B26;&#x5408;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/app-permission-mgmt-overview-V5#&#x6743;&#x9650;&#x4F7F;&#x7528;&#x7684;&#x57FA;&#x672C;&#x539F;&#x5219;" target="_blank">&#x6743;&#x9650;&#x4F7F;&#x7528;&#x7684;&#x57FA;&#x672C;&#x539F;&#x5219;</a>&#x3002;&#x7136;&#x540E;&#x53C2;&#x8003;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/declare-permissions-V5" target="_blank">&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x6743;&#x9650;&#x58F0;&#x660E;&#x6307;&#x5BFC;&#x6587;&#x6863;</a>&#x58F0;&#x660E;&#x5BF9;&#x5E94;&#x6743;&#x9650;&#x3002;</p>
</li>
<li><p>&#x4ECE;@ohos.net.connection&#x4E2D;&#x5BFC;&#x5165;connection&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x3002;</p>
</li>
<li><p>&#x8C03;&#x7528;createNetConnection&#x65B9;&#x6CD5;&#xFF0C;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x80FD;&#x529B;&#x3001;&#x7F51;&#x7EDC;&#x7C7B;&#x578B;&#x548C;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#xFF08;&#x53EF;&#x9009;&#xFF0C;&#x5982;&#x4E0D;&#x4F20;&#x5165;&#x4EE3;&#x8868;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#xFF1B;&#x521B;&#x5EFA;&#x4E0D;&#x540C;&#x4E8E;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x65F6;&#x53EF;&#x901A;&#x8FC7;&#x6307;&#x5B9A;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x5B8C;&#x6210;&#xFF09;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;NetConnection&#x5BF9;&#x8C61;&#x3002;</p>
</li>
<li><p>&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;on()&#x65B9;&#x6CD5;&#xFF0C;&#x4F20;&#x5165;type&#x548C;callback&#xFF0C;&#x8BA2;&#x9605;&#x76F8;&#x5E94;&#x4E8B;&#x4EF6;&#x3002;</p>
</li>
<li><p>&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;register()&#x65B9;&#x6CD5;&#xFF0C;&#x8BA2;&#x9605;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x7684;&#x901A;&#x77E5;&#x3002;</p>
</li>
<li><p>&#x5F53;&#x7F51;&#x7EDC;&#x53EF;&#x7528;&#x65F6;&#xFF0C;&#x4F1A;&#x6536;&#x5230;netAvailable&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#xFF1B;&#x5F53;&#x7F51;&#x7EDC;&#x4E0D;&#x53EF;&#x7528;&#x65F6;&#xFF0C;&#x4F1A;&#x6536;&#x5230;netUnavailable&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;</p>
</li>
<li><p>&#x5F53;&#x4E0D;&#x4F7F;&#x7528;&#x8BE5;&#x7F51;&#x7EDC;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;unregister()&#x65B9;&#x6CD5;&#xFF0C;&#x53D6;&#x6D88;&#x8BA2;&#x9605;&#x3002;</p>
</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-comment">// &#x5F15;&#x5165;&#x5305;&#x540D;</span>
<span class="hljs-keyword">import</span> connection from <span class="hljs-string">&apos;@ohos.net.connection&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } from <span class="hljs-string">&apos;@ohos.base&apos;</span>;

<span class="hljs-keyword">let</span> netSpecifier: connection.NetSpecifier = {
  netCapabilities: {
    <span class="hljs-comment">// &#x5047;&#x8BBE;&#x5F53;&#x524D;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;&#x662F;Wi-Fi&#xFF0C;&#x9700;&#x8981;&#x521B;&#x5EFA;&#x8702;&#x7A9D;&#x7F51;&#x7EDC;&#x8FDE;&#x63A5;&#xFF0C;&#x53EF;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x7C7B;&#x578B;&#x4E3A;&#x8702;&#x7A9D;&#x7F51;</span>
    bearerTypes: [connection.NetBearType.BEARER_CELLULAR],
    <span class="hljs-comment">// &#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x80FD;&#x529B;&#x4E3A;Internet</span>
    networkCap: [connection.NetCap.NET_CAPABILITY_INTERNET]
  },
};

<span class="hljs-comment">// &#x6307;&#x5B9A;&#x8D85;&#x65F6;&#x65F6;&#x95F4;&#x4E3A;10s(&#x9ED8;&#x8BA4;&#x503C;&#x4E3A;0)</span>
<span class="hljs-keyword">let</span> timeout = <span class="hljs-number">10</span> * <span class="hljs-number">1000</span>;

<span class="hljs-comment">// &#x521B;&#x5EFA;NetConnection&#x5BF9;&#x8C61;</span>
<span class="hljs-keyword">let</span> conn = connection.createNetConnection(netSpecifier, timeout);

<span class="hljs-comment">// &#x8BA2;&#x9605;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x72B6;&#x6001;&#x53D8;&#x5316;&#x7684;&#x901A;&#x77E5;</span>
conn.register((err: BusinessError, data: <span class="hljs-built_in">void</span>) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(err));
});

<span class="hljs-comment">// &#x8BA2;&#x9605;&#x4E8B;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x5F53;&#x524D;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x53EF;&#x7528;&#xFF0C;&#x901A;&#x8FC7;on_netAvailable&#x901A;&#x77E5;&#x7528;&#x6237;</span>
conn.on(<span class="hljs-string">&apos;netAvailable&apos;</span>, ((data: connection.NetHandle) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;net is available, netId is &quot;</span> + data.netId);
}));

<span class="hljs-comment">// &#x8BA2;&#x9605;&#x4E8B;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x5F53;&#x524D;&#x6307;&#x5B9A;&#x7F51;&#x7EDC;&#x4E0D;&#x53EF;&#x7528;&#xFF0C;&#x901A;&#x8FC7;on_netUnavailable&#x901A;&#x77E5;&#x7528;&#x6237;</span>
conn.on(<span class="hljs-string">&apos;netUnavailable&apos;</span>, ((data: <span class="hljs-built_in">void</span>) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;net is unavailable, data is &quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(data));
}));

<span class="hljs-comment">// &#x5F53;&#x4E0D;&#x4F7F;&#x7528;&#x8BE5;&#x7F51;&#x7EDC;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;unregister()&#x65B9;&#x6CD5;&#xFF0C;&#x53D6;&#x6D88;&#x8BA2;&#x9605;</span>
conn.unregister((err: BusinessError, data: <span class="hljs-built_in">void</span>) =&gt; {
});
</code></pre>
<h3 id="&#x6839;&#x636E;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x53CA;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;"><a name="&#x6839;&#x636E;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x53CA;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;" class="plugin-anchor" href="#&#x6839;&#x636E;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x53CA;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6839;&#x636E;&#x6570;&#x636E;&#x7F51;&#x7EDC;&#x67E5;&#x8BE2;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x53CA;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;</h3>
<h3 id="&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><a name="&#x5F00;&#x53D1;&#x6B65;&#x9AA4;" class="plugin-anchor" href="#&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F00;&#x53D1;&#x6B65;&#x9AA4;</h3>
<ol>
<li><p>&#x58F0;&#x660E;&#x63A5;&#x53E3;&#x8C03;&#x7528;&#x6240;&#x9700;&#x8981;&#x7684;&#x6743;&#x9650;&#xFF1A;ohos.permission.GET_NETWORK_INFO&#x3002;</p>
<p>&#x6B64;&#x6743;&#x9650;&#x7EA7;&#x522B;&#x4E3A;normal&#xFF0C;&#x5728;&#x7533;&#x8BF7;&#x6743;&#x9650;&#x524D;&#xFF0C;&#x5728;&#x7533;&#x8BF7;&#x6743;&#x9650;&#x524D;&#xFF0C;&#x8BF7;&#x4FDD;&#x8BC1;&#x7B26;&#x5408;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/app-permission-mgmt-overview-V5#&#x6743;&#x9650;&#x4F7F;&#x7528;&#x7684;&#x57FA;&#x672C;&#x539F;&#x5219;" target="_blank">&#x6743;&#x9650;&#x4F7F;&#x7528;&#x7684;&#x57FA;&#x672C;&#x539F;&#x5219;</a>&#x3002;&#x7136;&#x540E;&#x53C2;&#x8003;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/declare-permissions-V5" target="_blank">&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x6743;&#x9650;&#x58F0;&#x660E;&#x6307;&#x5BFC;&#x6587;&#x6863;</a>&#x58F0;&#x660E;&#x5BF9;&#x5E94;&#x6743;&#x9650;&#x3002;</p>
</li>
<li><p>&#x4ECE;@ohos.net.connection&#x4E2D;&#x5BFC;&#x5165;connection&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x3002;</p>
</li>
<li><p>&#x901A;&#x8FC7;&#x8C03;&#x7528;getDefaultNet&#x65B9;&#x6CD5;&#xFF0C;&#x83B7;&#x53D6;&#x9ED8;&#x8BA4;&#x7684;&#x6570;&#x636E;&#x7F51;&#x7EDC;(NetHandle)&#xFF1B;&#x6216;&#x8005;&#x901A;&#x8FC7;&#x8C03;&#x7528;getAllNets&#x65B9;&#x6CD5;&#xFF0C;&#x83B7;&#x53D6;&#x6240;&#x6709;&#x5904;&#x4E8E;&#x8FDE;&#x63A5;&#x72B6;&#x6001;&#x7684;&#x7F51;&#x7EDC;&#x5217;&#x8868;(Array<nethandle>)&#x3002;</nethandle></p>
</li>
<li><p>&#x8C03;&#x7528;getNetCapabilities&#x65B9;&#x6CD5;&#xFF0C;&#x83B7;&#x53D6;NetHandle&#x5BF9;&#x5E94;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x3002;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x5305;&#x542B;&#x4E86;&#x7F51;&#x7EDC;&#x7C7B;&#x578B;(&#x8702;&#x7A9D;&#x7F51;&#x7EDC;&#x3001;Wi-Fi&#x7F51;&#x7EDC;&#x3001;&#x4EE5;&#x592A;&#x7F51;&#x7F51;&#x7EDC;&#x7B49;)&#x3001;&#x7F51;&#x7EDC;&#x5177;&#x4F53;&#x80FD;&#x529B;&#x7B49;&#x7F51;&#x7EDC;&#x4FE1;&#x606F;&#x3002;</p>
</li>
<li><p>&#x8C03;&#x7528;getConnectionProperties&#x65B9;&#x6CD5;&#xFF0C;&#x83B7;&#x53D6;NetHandle&#x5BF9;&#x5E94;&#x7F51;&#x7EDC;&#x7684;&#x8FDE;&#x63A5;&#x4FE1;&#x606F;&#x3002;</p>
</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> connection from <span class="hljs-string">&apos;@ohos.net.connection&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } from <span class="hljs-string">&apos;@ohos.base&apos;</span>;

<span class="hljs-comment">// &#x6784;&#x9020;&#x5355;&#x4F8B;&#x5BF9;&#x8C61;</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> GlobalContext {
  <span class="hljs-keyword">public</span> netList: connection.NetHandle[] = [];
  <span class="hljs-keyword">public</span> netHandle: connection.NetHandle|<span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">constructor</span>() {}
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> instance: GlobalContext;
  <span class="hljs-keyword">private</span> _objects = <span class="hljs-keyword">new</span> Map&lt;<span class="hljs-built_in">string</span>, <span class="hljs-built_in">Object</span>&gt;();

  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> getContext(): GlobalContext {
    <span class="hljs-keyword">if</span> (!GlobalContext.instance) {
      GlobalContext.instance = <span class="hljs-keyword">new</span> GlobalContext();
    }
    <span class="hljs-keyword">return</span> GlobalContext.instance;
  }

  getObject(value: <span class="hljs-built_in">string</span>): <span class="hljs-built_in">Object</span> | <span class="hljs-literal">undefined</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._objects.get(value);
  }

  setObject(key: <span class="hljs-built_in">string</span>, objectClass: <span class="hljs-built_in">Object</span>): <span class="hljs-built_in">void</span> {
    <span class="hljs-keyword">this</span>._objects.set(key, objectClass);
  }
}

<span class="hljs-comment">// &#x8C03;&#x7528;getDefaultNet&#x65B9;&#x6CD5;&#xFF0C;&#x83B7;&#x53D6;&#x9ED8;&#x8BA4;&#x7684;&#x6570;&#x636E;&#x7F51;&#x7EDC;(NetHandle)</span>
connection.getDefaultNet((err: BusinessError, data:connection.NetHandle) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(err));
  <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(data));
  <span class="hljs-keyword">if</span> (data) {
    GlobalContext.getContext().netHandle = data;
  }
})

<span class="hljs-comment">// &#x83B7;&#x53D6;NetHandle&#x5BF9;&#x5E94;&#x7F51;&#x7EDC;&#x7684;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x3002;&#x80FD;&#x529B;&#x4FE1;&#x606F;&#x5305;&#x542B;&#x4E86;&#x7F51;&#x7EDC;&#x7C7B;&#x578B;&#x3001;&#x7F51;&#x7EDC;&#x5177;&#x4F53;&#x80FD;&#x529B;&#x7B49;&#x7F51;&#x7EDC;&#x4FE1;&#x606F;</span>
connection.getNetCapabilities(GlobalContext.getContext().netHandle, (err: BusinessError, data: connection.NetCapabilities) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(err));

  <span class="hljs-comment">// &#x83B7;&#x53D6;&#x7F51;&#x7EDC;&#x7C7B;&#x578B;(bearerTypes)</span>
  <span class="hljs-keyword">let</span> bearerTypes: Set&lt;<span class="hljs-built_in">number</span>&gt; = <span class="hljs-keyword">new</span> Set(data.bearerTypes);
  <span class="hljs-keyword">let</span> bearerTypesNum = <span class="hljs-built_in">Array</span>.from(bearerTypes.values());
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item of bearerTypesNum) {
    <span class="hljs-keyword">if</span> (item == <span class="hljs-number">0</span>) {
      <span class="hljs-comment">// &#x8702;&#x7A9D;&#x7F51;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;BEARER_CELLULAR&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">1</span>) {
      <span class="hljs-comment">// Wi-Fi&#x7F51;&#x7EDC;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;BEARER_WIFI&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">3</span>) {
      <span class="hljs-comment">// &#x4EE5;&#x592A;&#x7F51;&#x7F51;&#x7EDC;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;BEARER_ETHERNET&quot;</span>));
    }
  }

  <span class="hljs-comment">// &#x83B7;&#x53D6;&#x7F51;&#x7EDC;&#x5177;&#x4F53;&#x80FD;&#x529B;(networkCap)</span>
  <span class="hljs-keyword">let</span> itemNumber : Set&lt;<span class="hljs-built_in">number</span>&gt; = <span class="hljs-keyword">new</span> Set([<span class="hljs-number">0</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-number">15</span>, <span class="hljs-number">16</span>]);
  <span class="hljs-keyword">let</span> dataNumber = <span class="hljs-built_in">Array</span>.from(itemNumber.values());
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item of dataNumber) {
    <span class="hljs-keyword">if</span> (item == <span class="hljs-number">0</span>) {
      <span class="hljs-comment">// &#x8868;&#x793A;&#x7F51;&#x7EDC;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x8FD0;&#x8425;&#x5546;&#x7684;MMSC&#xFF08;Multimedia Message Service&#xFF0C;&#x591A;&#x5A92;&#x4F53;&#x77ED;&#x4FE1;&#x670D;&#x52A1;&#xFF09;&#x53D1;&#x9001;&#x548C;&#x63A5;&#x6536;&#x5F69;&#x4FE1;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;NET_CAPABILITY_MMS&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">11</span>) {
      <span class="hljs-comment">// &#x8868;&#x793A;&#x7F51;&#x7EDC;&#x6D41;&#x91CF;&#x672A;&#x88AB;&#x8BA1;&#x8D39;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;NET_CAPABILITY_NOT_METERED&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">12</span>) {
      <span class="hljs-comment">// &#x8868;&#x793A;&#x8BE5;&#x7F51;&#x7EDC;&#x5E94;&#x5177;&#x6709;&#x8BBF;&#x95EE;Internet&#x7684;&#x80FD;&#x529B;&#xFF0C;&#x8BE5;&#x80FD;&#x529B;&#x7531;&#x7F51;&#x7EDC;&#x63D0;&#x4F9B;&#x8005;&#x8BBE;&#x7F6E;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;NET_CAPABILITY_INTERNET&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">15</span>) {
      <span class="hljs-comment">// &#x8868;&#x793A;&#x7F51;&#x7EDC;&#x4E0D;&#x4F7F;&#x7528;VPN&#xFF08;Virtual Private Network&#xFF0C;&#x865A;&#x62DF;&#x4E13;&#x7528;&#x7F51;&#x7EDC;&#xFF09;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;NET_CAPABILITY_NOT_VPN&quot;</span>));
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (item == <span class="hljs-number">16</span>) {
      <span class="hljs-comment">// &#x8868;&#x793A;&#x8BE5;&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;Internet&#x7684;&#x80FD;&#x529B;&#x88AB;&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6210;&#x529F;&#x9A8C;&#x8BC1;&#xFF0C;&#x8BE5;&#x80FD;&#x529B;&#x7531;&#x7F51;&#x7EDC;&#x7BA1;&#x7406;&#x6A21;&#x5757;&#x8BBE;&#x7F6E;</span>
      <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(<span class="hljs-string">&quot;NET_CAPABILITY_VALIDATED&quot;</span>));
    }
  }
})
</code></pre>
<h2 id="websocket&#x8FDE;&#x63A5;"><a name="websocket&#x8FDE;&#x63A5;" class="plugin-anchor" href="#websocket&#x8FDE;&#x63A5;"><i class="fa fa-link" aria-hidden="true"></i></a>WebSocket&#x8FDE;&#x63A5;</h2>
<p>&#x4F7F;&#x7528;WebSocket&#x5EFA;&#x7ACB;&#x670D;&#x52A1;&#x5668;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x53CC;&#x5411;&#x8FDE;&#x63A5;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x901A;&#x8FC7;createWebSocket()&#x65B9;&#x6CD5;&#x521B;&#x5EFA;WebSocket&#x5BF9;&#x8C61;&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7;connect()&#x65B9;&#x6CD5;&#x8FDE;&#x63A5;&#x5230;&#x670D;&#x52A1;&#x5668;&#x3002;&#x5F53;&#x8FDE;&#x63A5;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;open&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#xFF0C;&#x4E4B;&#x540E;&#x5BA2;&#x6237;&#x7AEF;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;send()&#x65B9;&#x6CD5;&#x4E0E;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x3002;&#x5F53;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x4FE1;&#x606F;&#x7ED9;&#x5BA2;&#x6237;&#x7AEF;&#x65F6;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;message&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;&#x5F53;&#x5BA2;&#x6237;&#x7AEF;&#x4E0D;&#x8981;&#x6B64;&#x8FDE;&#x63A5;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8C03;&#x7528;close()&#x65B9;&#x6CD5;&#x4E3B;&#x52A8;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;&#xFF0C;&#x4E4B;&#x540E;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;close&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;</p>
<p>&#x82E5;&#x5728;&#x4E0A;&#x8FF0;&#x4EFB;&#x4E00;&#x8FC7;&#x7A0B;&#x4E2D;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;error&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;</p>
<p>&#x8BF4;&#x660E;</p>
<p>&#x5728;&#x4F7F;&#x7528;&#x6B64;&#x529F;&#x80FD;&#x524D;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x5B8C;&#x6210;<a href="https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/agc-help-harmonyos-server-domain-V5" target="_blank">&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;</a>&#x3002;</p>
<h2 id="&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><a name="&#x63A5;&#x53E3;&#x8BF4;&#x660E;" class="plugin-anchor" href="#&#x63A5;&#x53E3;&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x53E3;&#x8BF4;&#x660E;</h2>
<p>WebSocket&#x8FDE;&#x63A5;&#x529F;&#x80FD;&#x4E3B;&#x8981;&#x7531;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-websocket-V5" target="_blank">WebSocket</a>&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x3002;&#x4F7F;&#x7528;&#x8BE5;&#x529F;&#x80FD;&#x9700;&#x8981;&#x7533;&#x8BF7;ohos.permission.INTERNET&#x6743;&#x9650;&#x3002;&#x5177;&#x4F53;&#x63A5;&#x53E3;&#x8BF4;&#x660E;&#x5982;&#x4E0B;&#x8868;&#x3002;</p>
<table>
<thead>
<tr>
<th>&#x63A5;&#x53E3;&#x540D;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>createWebSocket()</td>
<td>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;&#x3002;</td>
</tr>
<tr>
<td>connect()</td>
<td>&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;</td>
</tr>
<tr>
<td>send()</td>
<td>&#x901A;&#x8FC7;WebSocket&#x8FDE;&#x63A5;&#x53D1;&#x9001;&#x6570;&#x636E;&#x3002;</td>
</tr>
<tr>
<td>close()</td>
<td>&#x5173;&#x95ED;WebSocket&#x8FDE;&#x63A5;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;open&apos;)</td>
<td>&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>off(type: &apos;open&apos;)</td>
<td>&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;message&apos;)</td>
<td>&#x8BA2;&#x9605;WebSocket&#x7684;&#x63A5;&#x6536;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6D88;&#x606F;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>off(type: &apos;message&apos;)</td>
<td>&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x63A5;&#x6536;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6D88;&#x606F;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;close&apos;)</td>
<td>&#x8BA2;&#x9605;WebSocket&#x7684;&#x5173;&#x95ED;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>off(type: &apos;close&apos;)</td>
<td>&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x5173;&#x95ED;&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>on(type: &apos;error&apos;)</td>
<td>&#x8BA2;&#x9605;WebSocket&#x7684;Error&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
<tr>
<td>off(type: &apos;error&apos;)</td>
<td>&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;Error&#x4E8B;&#x4EF6;&#x3002;</td>
</tr>
</tbody>
</table>
<h2 id="&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><a name="&#x5F00;&#x53D1;&#x6B65;&#x9AA4;" class="plugin-anchor" href="#&#x5F00;&#x53D1;&#x6B65;&#x9AA4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F00;&#x53D1;&#x6B65;&#x9AA4;</h2>
<ol>
<li>&#x5BFC;&#x5165;&#x9700;&#x8981;&#x7684;webSocket&#x6A21;&#x5757;&#x3002;</li>
<li>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;WebSocket&#x5BF9;&#x8C61;&#x3002;</li>
<li>&#xFF08;&#x53EF;&#x9009;&#xFF09;&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x3001;&#x6D88;&#x606F;&#x63A5;&#x6536;&#x3001;&#x5173;&#x95ED;&#x3001;Error&#x4E8B;&#x4EF6;&#x3002;</li>
<li>&#x6839;&#x636E;URL&#x5730;&#x5740;&#xFF0C;&#x53D1;&#x8D77;WebSocket&#x8FDE;&#x63A5;&#x3002;</li>
<li>&#x4F7F;&#x7528;&#x5B8C;WebSocket&#x8FDE;&#x63A5;&#x4E4B;&#x540E;&#xFF0C;&#x4E3B;&#x52A8;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;&#x3002;</li>
</ol>
<pre><code class="lang-javascript">&#x4F7F;&#x7528;WebSocket&#x5EFA;&#x7ACB;&#x670D;&#x52A1;&#x5668;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x53CC;&#x5411;&#x8FDE;&#x63A5;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x901A;&#x8FC7;createWebSocket()&#x65B9;&#x6CD5;&#x521B;&#x5EFA;WebSocket&#x5BF9;&#x8C61;&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7;connect()&#x65B9;&#x6CD5;&#x8FDE;&#x63A5;&#x5230;&#x670D;&#x52A1;&#x5668;&#x3002;&#x5F53;&#x8FDE;&#x63A5;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;open&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#xFF0C;&#x4E4B;&#x540E;&#x5BA2;&#x6237;&#x7AEF;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;send()&#x65B9;&#x6CD5;&#x4E0E;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x3002;&#x5F53;&#x670D;&#x52A1;&#x5668;&#x53D1;&#x4FE1;&#x606F;&#x7ED9;&#x5BA2;&#x6237;&#x7AEF;&#x65F6;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;message&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;&#x5F53;&#x5BA2;&#x6237;&#x7AEF;&#x4E0D;&#x8981;&#x6B64;&#x8FDE;&#x63A5;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8C03;&#x7528;close()&#x65B9;&#x6CD5;&#x4E3B;&#x52A8;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;&#xFF0C;&#x4E4B;&#x540E;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;close&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;

&#x82E5;&#x5728;&#x4E0A;&#x8FF0;&#x4EFB;&#x4E00;&#x8FC7;&#x7A0B;&#x4E2D;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x6536;&#x5230;error&#x4E8B;&#x4EF6;&#x7684;&#x56DE;&#x8C03;&#x3002;

&#x8BF4;&#x660E;
&#x5728;&#x4F7F;&#x7528;&#x6B64;&#x529F;&#x80FD;&#x524D;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x5B8C;&#x6210;&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x3002;

&#x63A5;&#x53E3;&#x8BF4;&#x660E;
WebSocket&#x8FDE;&#x63A5;&#x529F;&#x80FD;&#x4E3B;&#x8981;&#x7531;WebSocket&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x3002;&#x4F7F;&#x7528;&#x8BE5;&#x529F;&#x80FD;&#x9700;&#x8981;&#x7533;&#x8BF7;ohos.permission.INTERNET&#x6743;&#x9650;&#x3002;&#x5177;&#x4F53;&#x63A5;&#x53E3;&#x8BF4;&#x660E;&#x5982;&#x4E0B;&#x8868;&#x3002;

&#x63A5;&#x53E3;&#x540D;

&#x63CF;&#x8FF0;

createWebSocket()

&#x521B;&#x5EFA;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;&#x3002;

connect()

&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;

send()

&#x901A;&#x8FC7;WebSocket&#x8FDE;&#x63A5;&#x53D1;&#x9001;&#x6570;&#x636E;&#x3002;

close()

&#x5173;&#x95ED;WebSocket&#x8FDE;&#x63A5;&#x3002;

on(type: <span class="hljs-string">&apos;open&apos;</span>)

&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x4E8B;&#x4EF6;&#x3002;

off(type: <span class="hljs-string">&apos;open&apos;</span>)

&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x4E8B;&#x4EF6;&#x3002;

on(type: <span class="hljs-string">&apos;message&apos;</span>)

&#x8BA2;&#x9605;WebSocket&#x7684;&#x63A5;&#x6536;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6D88;&#x606F;&#x4E8B;&#x4EF6;&#x3002;

off(type: <span class="hljs-string">&apos;message&apos;</span>)

&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x63A5;&#x6536;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6D88;&#x606F;&#x4E8B;&#x4EF6;&#x3002;

on(type: <span class="hljs-string">&apos;close&apos;</span>)

&#x8BA2;&#x9605;WebSocket&#x7684;&#x5173;&#x95ED;&#x4E8B;&#x4EF6;&#x3002;

off(type: <span class="hljs-string">&apos;close&apos;</span>)

&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;&#x5173;&#x95ED;&#x4E8B;&#x4EF6;&#x3002;

on(type: <span class="hljs-string">&apos;error&apos;</span>)

&#x8BA2;&#x9605;WebSocket&#x7684;<span class="hljs-built_in">Error</span>&#x4E8B;&#x4EF6;&#x3002;

off(type: <span class="hljs-string">&apos;error&apos;</span>)

&#x53D6;&#x6D88;&#x8BA2;&#x9605;WebSocket&#x7684;<span class="hljs-built_in">Error</span>&#x4E8B;&#x4EF6;&#x3002;

&#x5F00;&#x53D1;&#x6B65;&#x9AA4;
&#x5BFC;&#x5165;&#x9700;&#x8981;&#x7684;webSocket&#x6A21;&#x5757;&#x3002;

&#x521B;&#x5EFA;&#x4E00;&#x4E2A;WebSocket&#x8FDE;&#x63A5;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;WebSocket&#x5BF9;&#x8C61;&#x3002;

&#xFF08;&#x53EF;&#x9009;&#xFF09;&#x8BA2;&#x9605;WebSocket&#x7684;&#x6253;&#x5F00;&#x3001;&#x6D88;&#x606F;&#x63A5;&#x6536;&#x3001;&#x5173;&#x95ED;&#x3001;<span class="hljs-built_in">Error</span>&#x4E8B;&#x4EF6;&#x3002;

&#x6839;&#x636E;URL&#x5730;&#x5740;&#xFF0C;&#x53D1;&#x8D77;WebSocket&#x8FDE;&#x63A5;&#x3002;

&#x4F7F;&#x7528;&#x5B8C;WebSocket&#x8FDE;&#x63A5;&#x4E4B;&#x540E;&#xFF0C;&#x4E3B;&#x52A8;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;&#x3002;

<span class="hljs-keyword">import</span> webSocket <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@ohos.net.webSocket&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@ohos.base&apos;</span>;

<span class="hljs-keyword">let</span> defaultIpAddress = <span class="hljs-string">&quot;ws://&quot;</span>;
<span class="hljs-keyword">let</span> ws = webSocket.createWebSocket();
ws.on(<span class="hljs-string">&apos;open&apos;</span>, (err: BusinessError, value: <span class="hljs-built_in">Object</span>) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;on open, status:&quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(value));
  <span class="hljs-comment">// &#x5F53;&#x6536;&#x5230;on(&apos;open&apos;)&#x4E8B;&#x4EF6;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;send()&#x65B9;&#x6CD5;&#x4E0E;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x901A;&#x4FE1;</span>
  ws.send(<span class="hljs-string">&quot;Hello, server!&quot;</span>, (err: BusinessError, value: boolean) =&gt; {
    <span class="hljs-keyword">if</span> (!err) {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Message sent successfully&quot;</span>);
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Failed to send the message. Err:&quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(err));
    }
  });
});
ws.on(<span class="hljs-string">&apos;message&apos;</span>, (err: BusinessError, value: string | <span class="hljs-built_in">ArrayBuffer</span>) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;on message, message:&quot;</span> + value);
  <span class="hljs-comment">// &#x5F53;&#x6536;&#x5230;&#x670D;&#x52A1;&#x5668;&#x7684;`bye`&#x6D88;&#x606F;&#x65F6;&#xFF08;&#x6B64;&#x6D88;&#x606F;&#x5B57;&#x6BB5;&#x4EC5;&#x4E3A;&#x793A;&#x610F;&#xFF0C;&#x5177;&#x4F53;&#x5B57;&#x6BB5;&#x9700;&#x8981;&#x4E0E;&#x670D;&#x52A1;&#x5668;&#x534F;&#x5546;&#xFF09;&#xFF0C;&#x4E3B;&#x52A8;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;</span>
  <span class="hljs-keyword">if</span> (value === <span class="hljs-string">&apos;bye&apos;</span>) {
    ws.close((err: BusinessError, value: boolean) =&gt; {
      <span class="hljs-keyword">if</span> (!err) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Connection closed successfully&quot;</span>);
      } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Failed to close the connection. Err: &quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(err));
      }
    });
  }
});
ws.on(<span class="hljs-string">&apos;close&apos;</span>, (err: BusinessError, value: webSocket.CloseResult) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;on close, code is &quot;</span> + value.code + <span class="hljs-string">&quot;, reason is &quot;</span> + value.reason);
});
ws.on(<span class="hljs-string">&apos;error&apos;</span>, (err: BusinessError) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;on error, error:&quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(err));
});
ws.connect(defaultIpAddress, (err: BusinessError, value: boolean) =&gt; {
  <span class="hljs-keyword">if</span> (!err) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Connected successfully&quot;</span>);
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Connection failed. Err:&quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(err));
  }
});
</code></pre>
<h2 id="&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;"><a name="&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;" class="plugin-anchor" href="#&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;</h2>
<p>&#x4E3A;&#x89C4;&#x8303;&#x5143;&#x670D;&#x52A1;&#x8BF7;&#x6C42;&#x57DF;&#x540D;&#x8303;&#x56F4;&#xFF0C;&#x63D0;&#x5347;&#x5143;&#x670D;&#x52A1;&#x4E0A;&#x67B6;&#x5BA1;&#x6838;&#x6548;&#x7387;&#x548C;&#x5E73;&#x53F0;&#x5408;&#x89C4;&#x7ECF;&#x8425;&#x5B89;&#x5168;&#x6027;&#xFF0C;AGC&#x57FA;&#x4E8E;&#x4E91;&#x5F00;&#x53D1;&#x529F;&#x80FD;&#x6784;&#x5EFA;&#x57DF;&#x540D;&#x7BA1;&#x63A7;&#x80FD;&#x529B;&#x4F5C;&#x4E3A;&#x5143;&#x670D;&#x52A1;&#x751F;&#x6001;&#x7BA1;&#x63A7;&#x7684;&#x91CD;&#x8981;&#x6293;&#x624B;&#xFF0C;&#x652F;&#x6301;&#x5F00;&#x53D1;&#x8005;&#x5728;&#x5143;&#x670D;&#x52A1;&#x4E0A;&#x67B6;&#x524D;&#x7533;&#x8BF7;&#x5F00;&#x653E;&#x4F7F;&#x7528;&#x7684;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x3002;&#x540E;&#x7EED;&#x5F53;&#x7528;&#x6237;&#x4F7F;&#x7528;&#x5143;&#x670D;&#x52A1;&#x65F6;&#xFF0C;&#x5C06;&#x6839;&#x636E;&#x8BE5;&#x5143;&#x670D;&#x52A1;&#x7684;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x8FDB;&#x884C;&#x57DF;&#x540D;&#x8BBF;&#x95EE;&#xFF0C;&#x4E3A;&#x7528;&#x6237;&#x63D0;&#x4F9B;&#x5B89;&#x5168;&#x53EF;&#x9760;&#x7684;&#x7F51;&#x7EDC;&#x73AF;&#x5883;&#xFF0C;&#x4ECE;&#x800C;&#x63D0;&#x5347;&#x7528;&#x6237;&#x4FE1;&#x4EFB;&#x5EA6;&#x548C;&#x6EE1;&#x610F;&#x5EA6;&#x3002;&#x5E76;&#x4E14;&#x57DF;&#x540D;&#x7BA1;&#x63A7;&#x652F;&#x6301;&#x5B9A;&#x671F;&#x81EA;&#x52A8;&#x5BFC;&#x5165;&#x5168;&#x5C40;&#x7981;&#x6B62;&#x6E05;&#x5355;&#x5185;&#x7684;&#x57DF;&#x540D;&#xFF0C;&#x5B9E;&#x73B0;&#x57DF;&#x540D;&#x6570;&#x636E;&#x7684;&#x81EA;&#x52A8;&#x5316;&#x66F4;&#x65B0;&#xFF0C;&#x65F6;&#x523B;&#x786E;&#x4FDD;&#x7F51;&#x7EDC;&#x7684;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#x548C;&#x4FE1;&#x606F;&#x7684;&#x5B89;&#x5168;&#x4F20;&#x8F93;&#x3002;</p>
<p>&#x8BF4;&#x660E;</p>
<p>&#x57DF;&#x540D;&#x7BA1;&#x63A7;&#x80FD;&#x529B;&#x4F1A;&#x968F;ROM&#x5347;&#x7EA7;&#x9010;&#x6B65;&#x843D;&#x5730;&#xFF0C;&#x4E3A;&#x4E86;&#x4E0D;&#x5F71;&#x54CD;&#x4F7F;&#x7528;&#x5DF2;&#x53D1;&#x5E03;&#x7684;&#x5143;&#x670D;&#x52A1;&#xFF0C;&#x5EFA;&#x8BAE;&#x5F00;&#x53D1;&#x8005;&#x5230;<a href="https://developer.huawei.com/consumer/cn/service/josp/agc/index.html" target="_blank">AppGallery Connect</a>&#x5B8C;&#x6210;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x3002;</p>
<p>&#x5982;&#x672A;&#x901A;&#x8FC7;AGC&#x914D;&#x7F6E;&#x76F8;&#x5173;&#x57DF;&#x540D;&#xFF0C;&#x5143;&#x670D;&#x52A1;&#x53D1;&#x8D77;&#x7684;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#x5C06;&#x4F1A;&#x88AB;&#x57DF;&#x540D;&#x7BA1;&#x63A7;&#x62E6;&#x622A;&#xFF0C;&#x5F71;&#x54CD;&#x7528;&#x6237;&#x4F7F;&#x7528;&#x3002;</p>
<h2 id="&#x524D;&#x63D0;&#x6761;&#x4EF6;"><a name="&#x524D;&#x63D0;&#x6761;&#x4EF6;" class="plugin-anchor" href="#&#x524D;&#x63D0;&#x6761;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x524D;&#x63D0;&#x6761;&#x4EF6;</h2>
<ul>
<li>&#x5F00;&#x53D1;&#x8005;&#x5E10;&#x53F7;&#x5DF2;&#x5B8C;&#x6210;<a href="https://developer.huawei.com/consumer/cn/doc/start/itrna-0000001076878172" target="_blank">&#x5B9E;&#x540D;&#x8BA4;&#x8BC1;</a>&#xFF0C;&#x4E14;&#x5F52;&#x5C5E;&#x5730;&#x4E3A;&#x4E2D;&#x56FD;&#x5927;&#x9646;&#x5730;&#x533A;&#x3002;</li>
</ul>
<h2 id="&#x914D;&#x989D;&#x9650;&#x5236;"><a name="&#x914D;&#x989D;&#x9650;&#x5236;" class="plugin-anchor" href="#&#x914D;&#x989D;&#x9650;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x989D;&#x9650;&#x5236;</h2>
<p>&#x540C;&#x4E00;&#x4E2A;&#x5143;&#x670D;&#x52A1;&#x6BCF;&#x4E2A;&#x81EA;&#x7136;&#x6708;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x4FEE;&#x6539;&#x6B21;&#x6570;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;50&#x6B21;&#x3002;&#x6BCF;&#x4FEE;&#x6539;&#x4E00;&#x6B21;&#x57DF;&#x540D;&#xFF0C;&#x5269;&#x4F59;&#x4FEE;&#x6539;&#x6B21;&#x6570;&#x51CF;&#x4E00;&#x3002;</p>
<p>&#x82E5;&#x4FEE;&#x6539;&#x6B21;&#x6570;&#x4E0D;&#x80FD;&#x6EE1;&#x8DB3;&#x60A8;&#x7684;&#x9700;&#x6C42;&#xFF0C;&#x60A8;&#x53EF;&#x53D1;&#x9001;&#x90AE;&#x4EF6;&#x5411;&#x534E;&#x4E3A;&#x8FD0;&#x8425;&#x4EBA;&#x5458;&#x7533;&#x8BF7;&#x653E;&#x5BBD;&#x9650;&#x5236;&#x3002;&#x5728;&#x6536;&#x5230;&#x60A8;&#x7684;&#x7533;&#x8BF7;&#x540E;&#xFF0C;&#x534E;&#x4E3A;&#x8FD0;&#x8425;&#x4EBA;&#x5458;&#x5C06;&#x5728;1-3&#x4E2A;&#x5DE5;&#x4F5C;&#x65E5;&#x5185;&#x4E3A;&#x60A8;&#x5B89;&#x6392;&#x5BF9;&#x63A5;&#x4EBA;&#x5458;&#x3002;&#x7533;&#x8BF7;&#x65B9;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x7533;&#x8BF7;&#x90AE;&#x7BB1;&#x5730;&#x5740;&#xFF1A;<a href="mailto:atomicservice@huawei.com" target="_blank">atomicservice@huawei.com</a>&#x3002;</li>
<li>&#x90AE;&#x4EF6;&#x6807;&#x9898;&#xFF1A;[&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;]-[&#x5143;&#x670D;&#x52A1;&#x540D;&#x79F0;]-[APP ID]-[Developer ID]&#xFF0C;APP ID&#x7B49;&#x67E5;&#x8BE2;&#x65B9;&#x6CD5;&#x53EF;&#x53C2;&#x89C1;<a href="https://developer.huawei.com/consumer/cn/doc/app/agc-help-appinfo-0000001100014694" target="_blank">&#x67E5;&#x770B;&#x5E94;&#x7528;&#x57FA;&#x672C;&#x4FE1;&#x606F;</a>&#x3002;</li>
<li>&#x90AE;&#x4EF6;&#x6B63;&#x6587;&#xFF1A;&#x8BF7;&#x8BF4;&#x660E;&#x7533;&#x8BF7;&#x653E;&#x5BBD;&#x4FEE;&#x6539;&#x6B21;&#x6570;&#x539F;&#x56E0;&#x3002;</li>
</ul>
<h2 id="&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;"><a name="&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;" class="plugin-anchor" href="#&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;</h2>
<p>1.&#x767B;&#x5F55;<a href="https://developer.huawei.com/consumer/cn/service/josp/agc/index.html" target="_blank">AppGallery Connect</a>&#xFF0C;&#x70B9;&#x51FB;&#x201C;&#x6211;&#x7684;&#x9879;&#x76EE;&#x201D;&#x3002;</p>
<p>2.&#x5728;&#x9879;&#x76EE;&#x5217;&#x8868;&#x4E2D;&#x70B9;&#x51FB;&#x60A8;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x7136;&#x540E;&#x5728;&#x9875;&#x9762;&#x9876;&#x7AEF;&#x9009;&#x62E9;&#x9700;&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x7684;&#x5143;&#x670D;&#x52A1;&#x540D;&#x79F0;&#x3002;</p>
<p>3.&#x5728;&#x5DE6;&#x4FA7;&#x5BFC;&#x822A;&#x680F;&#x9009;&#x62E9;&#x201C;&#x5F00;&#x53D1;&#x7BA1;&#x7406; &gt; &#x57DF;&#x540D;&#x914D;&#x7F6E; &gt; &#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x201D;&#xFF0C;&#x8FDB;&#x5165;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x4E3B;&#x754C;&#x9762;&#x3002;</p>
<p>4.&#x5F53;&#x524D;&#x652F;&#x6301;&#x914D;&#x7F6E;httpRequest&#x3001;webSocket&#x3001;download&#x3001;upload&#x56DB;&#x79CD;&#x670D;&#x52A1;&#x5668;&#x7C7B;&#x578B;&#x7684;&#x57DF;&#x540D;&#xFF0C;&#x70B9;&#x51FB;&#x201C;&#x4FEE;&#x6539;&#x201D;&#x3002;</p>
<p>5.&#x5728;&#x201C;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x201D;&#x5F39;&#x6846;&#x4E2D;&#xFF0C;&#x6839;&#x636E;&#x60A8;&#x7684;&#x670D;&#x52A1;&#x5668;&#x7C7B;&#x578B;&#xFF0C;&#x5728;&#x5BF9;&#x5E94;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x8F93;&#x5165;&#x6846;&#x4E2D;&#x8F93;&#x5165;&#x8981;&#x65B0;&#x589E;&#x7684;&#x57DF;&#x540D;&#x3002;</p>
<p>&#x57DF;&#x540D;&#x4EC5;&#x652F;&#x6301;&#x82F1;&#x6587;&#x5927;&#x5C0F;&#x5199;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x4EE5;&#x53CA;&#x7B26;&#x53F7;&#x201C;-&#x201D;&#x201C;.&#x201D;&#xFF0C;&#x4E14;&#x5355;&#x4E2A;&#x57DF;&#x540D;&#x957F;&#x5EA6;&#x4E0D;&#x80FD;&#x8D85;&#x8FC7;128&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x4E0D;&#x540C;&#x57DF;&#x540D;&#x4E4B;&#x95F4;&#x4EE5;&#x82F1;&#x6587;&quot;;&quot;&#x5206;&#x9694;&#x3002;</p>
<p>&#x6CE8;&#x610F;</p>
<ul>
<li>&#x57DF;&#x540D;&#x53EA;&#x652F;&#x6301;HTTPS&#x548C;WSS&#x534F;&#x8BAE;&#x3002;</li>
<li>&#x57DF;&#x540D;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;IP&#x5730;&#x5740;&#x6216;localhost&#x3002;</li>
<li>&#x4E0D;&#x53EF;&#x914D;&#x7F6E;&#x5168;&#x5C40;&#x7981;&#x6B62;&#x6E05;&#x5355;&#x5185;&#x7684;&#x57DF;&#x540D;&#x3002;</li>
<li>&#x5355;&#x9879;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x6570;&#x91CF;&#x6700;&#x591A;&#x4E0D;&#x8D85;&#x8FC7;200&#x4E2A;&#x3002;</li>
</ul>
<table>
<thead>
<tr>
<th>&#x914D;&#x7F6E;&#x9879;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>httpRequest&#x5408;&#x6CD5;&#x57DF;&#x540D;</td>
<td>httpRequest&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#xFF0C;&#x4EE5;&#x201C;<a href="https://&#x201D;&#x5F00;&#x5934;" target="_blank">https://&#x201D;&#x5F00;&#x5934;</a></td>
</tr>
<tr>
<td>webSocket&#x5408;&#x6CD5;&#x57DF;&#x540D;</td>
<td>webSocket&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#xFF0C;&#x4EE5;&#x201C;wss://&#x201D;&#x5F00;&#x5934;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x7AEF;&#x53E3;&#xFF0C;&#x9ED8;&#x8BA4;&#x5141;&#x8BB8;&#x8BF7;&#x6C42;&#x8BE5;&#x57DF;&#x540D;&#x4E0B;&#x6240;&#x6709;&#x7AEF;&#x53E3;&#x3002;</td>
</tr>
<tr>
<td>download&#x5408;&#x6CD5;&#x57DF;&#x540D;</td>
<td>download&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#xFF0C;&#x4EE5;&#x201C;<a href="https://&#x201D;&#x5F00;&#x5934;" target="_blank">https://&#x201D;&#x5F00;&#x5934;</a></td>
</tr>
<tr>
<td>upload&#x5408;&#x6CD5;&#x57DF;&#x540D;</td>
<td>upload&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#xFF0C;&#x4EE5;&#x201C;<a href="https://&#x201D;&#x5F00;&#x5934;" target="_blank">https://&#x201D;&#x5F00;&#x5934;</a></td>
</tr>
</tbody>
</table>
<p>6.&#x914D;&#x7F6E;&#x57DF;&#x540D;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x82E5;&#x63D0;&#x793A;&#x201C;&#x8F93;&#x5165;&#x5185;&#x5BB9;&#x5305;&#x542B;&#x975E;&#x6CD5;&#x57DF;&#x540D;&#x201D;&#xFF0C;&#x53EF;&#x70B9;&#x51FB;&#x63D0;&#x793A;&#x4FE1;&#x606F;&#x65C1;&#x8FB9;&#x7684;&#x201C;&#x67E5;&#x770B;&#x8BE6;&#x60C5;&#x201D;&#x67E5;&#x770B;&#x5177;&#x4F53;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x3002;</p>
<p>7.&#x6839;&#x636E;&#x201C;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x201D;&#x5F39;&#x6846;&#x63D0;&#x793A;&#x4FE1;&#x606F;&#xFF0C;&#x5BF9;&#x62A5;&#x9519;&#x57DF;&#x540D;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x3002;</p>
<p>&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x9519;&#x8BEF;&#x6709;&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x5931;&#x8D25;&#x539F;&#x56E0;</th>
<th>&#x89E3;&#x51B3;&#x65B9;&#x6CD5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x8BE5;&#x57DF;&#x540D;&#x534F;&#x8BAE;&#x5934;&#x975E;&#x6CD5;</td>
<td>&#x6309;&#x7167;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x7C7B;&#x578B;&#x4FEE;&#x6539;&#x4E3A;&#x5408;&#x6CD5;&#x534F;&#x8BAE;&#x5934;&#x3002;httpRequest/download/upload&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x4EE5;&#x201C;<a href="https://&#x201D;&#x5F00;&#x5934;&#x3002;webSocket&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x4EE5;&#x201C;wss://&#x201D;&#x5F00;&#x5934;&#x3002;" target="_blank">https://&#x201D;&#x5F00;&#x5934;&#x3002;webSocket&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x4EE5;&#x201C;wss://&#x201D;&#x5F00;&#x5934;&#x3002;</a></td>
</tr>
<tr>
<td>&#x4E0D;&#x80FD;&#x4F7F;&#x7528;IP&#x5730;&#x5740;&#x4F5C;&#x4E3A;&#x57DF;&#x540D;</td>
<td>&#x8BBE;&#x7F6E;&#x4E3A;&#x5408;&#x6CD5;&#x57DF;&#x540D;&#x3002;</td>
</tr>
<tr>
<td>&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x672C;&#x5730;&#x57DF;&#x540D;localhost</td>
<td>&#x8BBE;&#x7F6E;&#x4E3A;&#x5408;&#x6CD5;&#x57DF;&#x540D;&#x3002;</td>
</tr>
<tr>
<td>&#x57DF;&#x540D;&#x683C;&#x5F0F;&#x4E0D;&#x5408;&#x6CD5;&#xFF0C;&#x57DF;&#x540D;&#x683C;&#x5F0F;&#x53EA;&#x652F;&#x6301;&#x82F1;&#x6587;&#x5927;&#x5C0F;&#x5199;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x53CA;&#x7B26;&#x53F7;&#x201C;-&#x201D;&#x201C;.&#x201D;</td>
<td>&#x53BB;&#x9664;&#x57DF;&#x540D;&#x4E2D;&#x5305;&#x542B;&#x7684;&#x975E;&#x6CD5;&#x5B57;&#x7B26;&#x3002;</td>
</tr>
<tr>
<td>webSocket&#x57DF;&#x540D;&#x4E0D;&#x80FD;&#x5305;&#x542B;&#x7AEF;&#x53E3;&#x53F7;</td>
<td>webSocket&#x670D;&#x52A1;&#x5668;&#x7C7B;&#x578B;&#x7684;&#x57DF;&#x540D;&#x4E0D;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x7AEF;&#x53E3;&#xFF0C;&#x9ED8;&#x8BA4;&#x5141;&#x8BB8;&#x8BF7;&#x6C42;&#x8BE5;&#x57DF;&#x540D;&#x4E0B;&#x6240;&#x6709;&#x7AEF;&#x53E3;&#xFF0C;&#x53BB;&#x9664;&#x57DF;&#x540D;&#x4E2D;&#x5305;&#x542B;&#x7684;&#x7AEF;&#x53E3;&#x3002;</td>
</tr>
<tr>
<td>&#x57DF;&#x540D;&#x957F;&#x5EA6;&#x8D85;&#x8FC7;128</td>
<td>&#x5355;&#x4E2A;&#x57DF;&#x540D;&#x957F;&#x5EA6;&#x4E0D;&#x8D85;&#x8FC7;128&#x4E2A;&#x5B57;&#x7B26;&#x3002;</td>
</tr>
<tr>
<td>&#x4E3A;&#x4FDD;&#x969C;&#x5B89;&#x5168;&#x4E0D;&#x53EF;&#x4F7F;&#x7528;&#x6B64;&#x57DF;&#x540D;&#x5730;&#x5740;</td>
<td>&#x914D;&#x7F6E;&#x7684;&#x57DF;&#x540D;&#x5B58;&#x5728;&#x4E8E;&#x57DF;&#x540D;&#x7981;&#x6B62;&#x6E05;&#x5355;&#x5185;&#xFF0C;&#x5DF2;&#x88AB;&#x5168;&#x5C40;&#x7981;&#x7528;&#xFF0C;&#x9700;&#x66FF;&#x6362;&#x4E3A;&#x5408;&#x6CD5;&#x57DF;&#x540D;&#x3002;</td>
</tr>
</tbody>
</table>
<p>8.&#x57DF;&#x540D;&#x6B63;&#x786E;&#x914D;&#x7F6E;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x70B9;&#x51FB;&#x201C;&#x63D0;&#x4EA4;&#x201D;&#x5C06;&#x65B0;&#x589E;&#x57DF;&#x540D;&#x63D0;&#x4EA4;&#x5BA1;&#x6838;&#x3002;&#x5F53;&#x5F39;&#x51FA;&#x63D0;&#x793A;&#x6846;&#x663E;&#x793A;&#x201C;&#x63D0;&#x4EA4;&#x6210;&#x529F;&#x201D;&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x65B0;&#x589E;&#x57DF;&#x540D;&#x6210;&#x529F;&#xFF0C;&#x70B9;&#x51FB;&#x201C;&#x786E;&#x8BA4;&#x201D;&#x5C06;&#x8FD4;&#x56DE;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x5217;&#x8868;&#x3002;</p>
<p>9.&#x5728;&#x57DF;&#x540D;&#x5217;&#x8868;&#xFF0C;&#x60A8;&#x53EF;&#x770B;&#x5230;&#x4E0D;&#x540C;&#x670D;&#x52A1;&#x5668;&#x4E0B;&#x5DF2;&#x914D;&#x7F6E;&#x7684;&#x57DF;&#x540D;&#x3001;&#x5DF2;&#x914D;&#x7F6E;&#x7684;&#x57DF;&#x540D;&#x6570;&#x91CF;&#x3001;&#x53EF;&#x914D;&#x7F6E;&#x7684;&#x57DF;&#x540D;&#x603B;&#x6570;&#x91CF;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x540E;&#x7EED;&#x82E5;&#x60A8;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x6216;&#x5220;&#x9664;&#x5DF2;&#x6DFB;&#x52A0;&#x7684;&#x57DF;&#x540D;&#xFF0C;&#x53EF;&#x70B9;&#x51FB;&#x201C;&#x4FEE;&#x6539;&#x201D;&#x8FDB;&#x884C;&#x5237;&#x65B0;&#x3002;</p>
<h2 id="&#x8DF3;&#x8FC7;&#x57DF;&#x540D;&#x6821;&#x9A8C;"><a name="&#x8DF3;&#x8FC7;&#x57DF;&#x540D;&#x6821;&#x9A8C;" class="plugin-anchor" href="#&#x8DF3;&#x8FC7;&#x57DF;&#x540D;&#x6821;&#x9A8C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8DF3;&#x8FC7;&#x57DF;&#x540D;&#x6821;&#x9A8C;</h2>
<p>&#x5728;&#x5143;&#x670D;&#x52A1;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x60A8;&#x53EF;&#x4EE5;&#x5728;HarmonyOS&#x8BBE;&#x5907;&#x7AEF;&#x4E34;&#x65F6;&#x5F00;&#x542F;&#x201C;<strong>&#x5F00;&#x53D1;&#x4E2D;&#x5143;&#x670D;&#x52A1;&#x8C41;&#x514D;&#x7BA1;&#x63A7;</strong>&#x201D;&#x9009;&#x9879;&#xFF0C;&#x8DF3;&#x8FC7;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x7684;&#x6821;&#x9A8C;&#x3002;&#x64CD;&#x4F5C;&#x65B9;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li>&#x6253;&#x5F00;&#x201C;&#x8BBE;&#x7F6E; &gt; &#x5173;&#x4E8E;&#x672C;&#x673A;&#x201D;&#xFF0C;&#x591A;&#x6B21;&#x70B9;&#x51FB;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x6253;&#x5F00;&#x5F00;&#x53D1;&#x8005;&#x6A21;&#x5F0F;&#x3002;</li>
<li>&#x6253;&#x5F00;&#x201C;&#x8BBE;&#x7F6E; &gt; &#x7CFB;&#x7EDF;&#x201D;&#xFF0C;&#x5728;&#x4E0B;&#x65B9;&#x627E;&#x5230;&#x201C;&#x5F00;&#x53D1;&#x8005;&#x9009;&#x9879;&#x201D;&#x5E76;&#x70B9;&#x51FB;&#x8FDB;&#x5165;&#x3002;</li>
<li>&#x5728;&#x4E0B;&#x65B9;&#x201C;&#x5E94;&#x7528;&#x201D;&#x533A;&#x57DF;&#xFF0C;&#x6253;&#x5F00;&#x201C;&#x5F00;&#x53D1;&#x4E2D;&#x5143;&#x670D;&#x52A1;&#x8C41;&#x514D;&#x7BA1;&#x63A7;&#x201D;&#x5F00;&#x5173;&#x3002;</li>
</ol>
<p>&#x9009;&#x9879;&#x5F00;&#x542F;&#x540E;&#x5728;&#x8BBE;&#x5907;&#x4E0A;&#x8FD0;&#x884C;&#x975E;&#x6B63;&#x5F0F;&#x7248;&#x672C;&#x7684;&#x5143;&#x670D;&#x52A1;&#x65F6;&#xFF0C;&#x5C06;&#x4E0D;&#x518D;&#x8FDB;&#x884C;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x7684;&#x6821;&#x9A8C;&#x3002;</p>
<p>&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5EFA;&#x8BAE;&#x60A8;&#x5173;&#x95ED;&#x6B64;&#x9009;&#x9879;&#x8FDB;&#x884C;&#x5F00;&#x53D1;&#xFF0C;&#x5E76;&#x5728;&#x5404;&#x5E73;&#x53F0;&#x4E0B;&#x8FDB;&#x884C;&#x6D4B;&#x8BD5;&#xFF0C;&#x4EE5;&#x786E;&#x8BA4;&#x670D;&#x52A1;&#x5668;&#x57DF;&#x540D;&#x914D;&#x7F6E;&#x6B63;&#x786E;&#x3002;</p>
<footer class="page-footer"><span class="copyright">powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2024-11-05 16:05:57
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                </div>
                <script src="https://my.openwrite.cn/js/readmore.js"></script>
                <script>
                    var enablePlugin = false;
                    var allowDomain = "localhost";
                    if(allowDomain){
                        var currentDomain = location.hostname;
                        if ($.isArray(allowDomain)) {
                            $.each(allowDomain, function(index, item) {
                                if (currentDomain == item) {
                                    enablePlugin = true;
                                    return false;
                                }
                            });
                        }else{
                           if (currentDomain == allowDomain) {
                                enablePlugin = true;
                            }
                        }
                    }else{
                        enablePlugin = true;
                    }
                    
                    if(enablePlugin){
                        var isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
                        if (!isMobile) {
                            var btw = new BTWPlugin();
                            btw.init({"allowDomain":"localhost","blogId":"27976-1678928361372-483","name":"坚果派","qrcode":"https://luckly007.oss-cn-beijing.aliyuncs.com/images/image-20230316085818226.png","keyword":"鸿蒙坚果","id":"vip-container"});
                        }
                    }
                </script> 
          </section>
          
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>
 
          <div class="book-footer">
            
            <div class="donate">
              <div></div>
              <button class="donate-btn" onclick="showModal()">赞赏</button>
            </div>
             
          </div>
          
        </div>
      </div>
      
    </div>

        
  </div>
  <script>
    function showModal() {
      document.getElementsByClassName("mask")[0].style.display = "block";
      document.getElementsByClassName("donate-modal")[0].style.display =
        "block";
    }
    // 切换赞赏码
    function showDonateImg(num) {
      let alipay = "";
      let wxpay = ""
      if(num){
        wxpay = "hidden"
      }else{
        alipay = "hidden"
      }
      document.getElementById("wxpay-code").hidden = wxpay;
      document.getElementById("alipay-code").hidden = alipay;
      document.getElementsByName("pay-way")[num].checked = "checked";
    }

    // 关闭赞赏框
    function closeDonateModal() {
      document.getElementsByClassName("mask")[0].style.display = "none";
      document.getElementsByClassName("donate-modal")[0].style.display = "none";
    }

    var gitbook = gitbook || [];
    gitbook.push(function () {
      gitbook.page.hasChanged({"page":{"title":"12.1网络","level":"1.12.1","depth":2,"next":{"title":"数据","level":"1.12.2","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-database-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-database-V5","articles":[]},"previous":{"title":"12.基础能力开发","level":"1.12","depth":1,"ref":"","articles":[{"title":"12.1网络","level":"1.12.1","depth":2,"path":"chapter12/12.1网络.md","ref":"./chapter12/12.1网络.md","articles":[]},{"title":"数据","level":"1.12.2","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-database-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-database-V5","articles":[]},{"title":"文件","level":"1.12.3","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-file-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-file-development-V5","articles":[]},{"title":"音视频","level":"1.12.4","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-audio-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-audio-development-V5","articles":[]},{"title":"媒体会话","level":"1.12.5","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-avsession-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-avsession-development-V5","articles":[]},{"title":"相机","level":"1.12.6","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-camera-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-camera-V5","articles":[]},{"title":"媒体库","level":"1.12.7","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-media-library-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-media-library-development-V5","articles":[]},{"title":"图片","level":"1.12.8","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-image-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-image-development-V5","articles":[]},{"title":"窗口","level":"1.12.9","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-window-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-window-development-V5","articles":[]},{"title":"设备管理","level":"1.12.10","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-device-management-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-device-management-V5","articles":[]},{"title":"基础通信","level":"1.12.11","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-connectivity-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-connectivity-V5","articles":[]},{"title":"联系人","level":"1.12.12","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-contacts-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-contacts-V5","articles":[]},{"title":"Web","level":"1.12.13","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-web-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-web-development-V5","articles":[]},{"title":"元服务分享","level":"1.12.14","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-service-sharing-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-service-sharing-V5","articles":[]},{"title":"AI能力","level":"1.12.15","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-ai-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-ai-development-V5","articles":[]},{"title":"运动健康","level":"1.12.16","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-health-service-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-health-service-development-V5","articles":[]},{"title":"云开发","level":"1.12.17","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-cloud-foundation-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-cloud-foundation-development-V5","articles":[]},{"title":"安全","level":"1.12.18","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-security-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-security-development-V5","articles":[]},{"title":"本地化开发服务","level":"1.12.19","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-localization-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-localization-V5","articles":[]},{"title":"长时任务","level":"1.12.20","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-backgroundtask-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-backgroundtask-V5","articles":[]},{"title":"日志","level":"1.12.21","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-log-development-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-log-development-V5","articles":[]},{"title":"ArkTS语言基础类库","level":"1.12.22","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkts-utils-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkts-utils-V5","articles":[]},{"title":"自动化测试","level":"1.12.23","depth":2,"url":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkxtest-guidelines-V5","ref":"https://developer.huawei.com/consumer/cn/doc/atomic-guides-V5/atomic-arkxtest-guidelines-V5","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github-buttons@2.1.0","edit-link","splitter","tbfed-pagefooter","expandable-chapters","chapter-fold","back-to-top-button","code","pageview-count","popup","search-plus","-lunr","-search","splitter","-sharing","sharing-plus","theme-lou","mind-maps","emphasize","anchors","changyan","readmore","livereload","ace","livereload"],"root":".","styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"expandable-chapters":{}},"emphasize":{},"ace":{},"livereload":{},"splitter":{},"readmore":{"allowDomain":"localhost","blogId":"27976-1678928361372-483","name":"坚果派","qrcode":"https://luckly007.oss-cn-beijing.aliyuncs.com/images/image-20230316085818226.png","keyword":"鸿蒙坚果"},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"theme-lou":{"hide-elements":[".summary .gitbook-link",".summary .divider"],"color":"#FF4848","book-anchor-title":"本章目录","copyright":{"author":"vx:nut_pie"},"forbidCopy":true,"logo":"assets/logo.png","book-summary-title":"文章目录","search-placeholder":"输入关键字搜索","copyrightLogo":"assets/copyright.png","favicon":"assets/avatar.png","appleTouchIconPrecomposed152":"assets/avatar.png"},"changyan":{"appid":"cyvHoCPAs","conf":"0440cfc4168ba95d73cfc52dd4d5c60b"},"fontsettings":{"theme":"white","family":"sans","size":2},"mind-maps":{},"highlight":{},"back-to-top-button":{},"pageview-count":{},"github-buttons":{"repo":"jianguo888/docsify","types":["star","watch","fork"],"size":"small"},"sharing":{"qq":false,"qzone":false,"weibo":false,"wechat":false,"all":["qq","qzone","weibo","wechat"]},"edit-link":{"label":"编辑此页","base":"https://atomgit.com/nutpi/atomic-service"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"坚果派","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"themeLou":{"nav":[{"target":"_blank","url":"https://www.gitbook.com/","name":"坚果派官网"},{"target":"_blank","url":"https://www.npmjs.com/package/package","name":"ArkUI实战"},{"target":"_blank","url":"https://space.bilibili.com/480883651","name":"HarmonyOS NEXT应用开发"},{"target":"_blank","url":"https://blog.51cto.com/jianguo","name":"OpenHarmony应用开发"}],"footer":{"donate":{"wechat":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","message":"随意打赏，但不要超过一顿早餐钱 💕","wxpay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","alipay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png","nickname":"坚果","button":"打赏","wechatText":"微信","alipayText":"支付宝","title":"『赠人玫瑰 🌹 手有余香 』","avatar":"https://luckly007.oss-cn-beijing.aliyuncs.com/uPic/avatar.jpg"},"copyright":false}}},"title":"元服务开发实践","language":"zh-hans","gitbook":"*","description":"元服务开发实践电子书教程"},"file":{"path":"chapter12/12.1网络.md","mtime":"2024-11-05T08:05:57.742Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-11-09T06:21:58.784Z"},"basePath":"..","book":{"language":""}});
    });
  </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-mind-maps/mindmaps.dist.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-changyan/changyan.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-lou/lou.js"></script>
        
    

    </body>
</html>

